#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

string a, b;
int len1, len2, i, j;
vector<vector<int> > dp;

int main()
{
    while (cin >> a >> b) {
        // init
        len1 = a.size();
        len2 = b.size();
        dp.resize(len1);
        for (i=0; i<len1; ++i)
            dp[i].resize(len2);
        //dp[0][0] = (a[0] == b[0]) ? 1 : 0;
        for (i=0; i<len1; ++i)
            for (j=0; j<len2; ++j)
            {
                dp[i][j] = (a[i] == b[j]) ? 1:0;
                if (i>0 && j>0) dp[i][j] += dp[i-1][j-1];
                if (i>0) dp[i][j] = max(dp[i][j], dp[i-1][j]);
                if (j>0) dp[i][j] = max(dp[i][j], dp[i][j-1]); 
            }  
        printf("%d\n", dp[len1-1][len2-1]);  
    }        
    return 0;
}    
